package com.achievement.controller;

import com.achievement.domain.dto.PaperEmbodyDTO;
import com.achievement.domain.param.PaperEmbodyParam;
import com.achievement.domain.vo.PaperEmbodyVO;
import com.achievement.service.IPaperEmbodyService;
import com.common.annotation.Anonymous;
import com.common.annotation.Log;
import com.common.core.controller.BaseController;
import com.common.core.domain.AjaxResult;
import com.common.core.page.TableDataInfo;
import com.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * PaperEmbodyController
 * 成果管理，科研成果，论文收录补录
 */

@RestController
@RequestMapping("/achievement/paperEmbody")
@Api(tags = "成果管理模块---论文收录补录")
public class PaperEmbodyController extends BaseController {

    @Autowired
    private IPaperEmbodyService paperEmbodyService;

    /**
     * 查询论文收录补录列表
     */
    @PreAuthorize("@ss.hasPermi('achievement:paperEmbody:list')")
    @Log(title = "查询论文收录补录列表")
    @ApiOperation(value = "查询论文收录补录列表",notes = "查询论文收录补录列表")
    @GetMapping(value = "/list")
    public TableDataInfo list(PaperEmbodyParam param) {
        startPage();
        List<PaperEmbodyVO> list = paperEmbodyService.selectByPage(param);
        return getDataTable(list);
    }

    /**
     * 左上方统计 通过，退回，待审核
     * @param param 检索参数
     * @return AjaxResult
     */
    @PreAuthorize("@ss.hasPermi('achievement:paperEmbody:list')")
    @ApiOperation(value = "左上方统计 通过，退回，待审核",notes = "左上方统计 通过，退回，待审核")
    @GetMapping(value = "/list-statistics")
    public AjaxResult listStatistics(PaperEmbodyParam param)
    {
        List<HashMap<String, Integer>> list =paperEmbodyService.listStatistics(param);

        return success(list);
    }

    /**
     * 论文收录补录查看详情
     */
    @PreAuthorize("@ss.hasPermi('achievement:paperEmbody:query')")
    @Log(title = "论文收录补录查看详情")
    @ApiOperation(value = "论文收录补录查看详情",notes = "论文收录补录查看详情")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(paperEmbodyService.getInfoById(id));
    }

    /**
     * 新增论文收录补录
     */
    @PreAuthorize("@ss.hasPermi('achievement:paperEmbody:add')")
    @Log(title = "新增论文收录补录", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增论文收录补录",notes = "新增论文收录补录")
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PaperEmbodyDTO dto) {
        return paperEmbodyService.add(dto);
    }

    /**
     * 删除论文收录补录
     */
    @PreAuthorize("@ss.hasPermi('achievement:paperEmbody:remove')")
    @Log(title = "删除论文收录补录", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除论文收录补录",notes = "删除论文收录补录")
    @DeleteMapping("/del/{ids}")
    public AjaxResult del(@PathVariable List<String> ids)
    {
        return toAjax(paperEmbodyService.batchRemove(ids));
    }
}
